# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=kopia
pkgver=0.10.7
pkgrel=2
pkgdesc="Fast and secure backup tool"
url="https://kopia.io/"
license="Apache-2.0"
arch="all !armhf !armv7 !x86" # tests fail with out of memory error
makedepends="go"
subpackages="$pkgname-bash-completion $pkgname-zsh-completion"
checkdepends="openssh-keygen"
source="https://github.com/kopia/kopia/archive/v$pkgver/kopia-$pkgver.tar.gz
	skip-docker-tests.patch
	"

export GOFLAGS="$GOFLAGS -trimpath -mod=readonly -modcacherw"
export GOPATH="$srcdir"
export CGO_ENABLED=0

build() {
	go build -ldflags "-s -w -X github.com/kopia/kopia/repo.BuildVersion=$pkgver"

	./kopia --completion-script-bash > $pkgname.bash
	./kopia --completion-script-zsh > $pkgname.zsh
}

check() {
	go test -tags testing ./...
}

package() {
	install -Dm755 kopia "$pkgdir"/usr/bin/kopia

	install -Dm644 $pkgname.bash "$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 $pkgname.zsh "$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
e66897d1fd09d0ac538f6d27a1294917fc41f77288428768ee08cc7dd286b4e418d28ccdb6ce3fcf60ebc31cce91821febdf04ad0118ad8ad698912823445fea  kopia-0.10.7.tar.gz
6c1c8ca52d83c940c561f11adc18298147882b709810edd8c6560c8988ff1bd30dae2adba4c18055d283e7c2c655a6c6f10c3951829826d6fe5eea20c8cb821d  skip-docker-tests.patch
"
